package com.server.service.impl;

import com.common.bean.Dept;
import com.common.service.DeptService;
import com.server.annotation.RpcBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.UUID;

/**
 * @author Zixiang Hu
 * @description 主要拿来模拟数据库操作
 * @create 2021-01-21-20:11
 */
@Slf4j
@RpcBean
public class DeptServiceImpl implements DeptService {
    @Override
    public Dept getDeptById(Integer id) {
        log.info("客户端查询了id为{}的部门", id);
        Dept dept = Dept.builder().deptName("部门名称：" + UUID.randomUUID().toString().substring(0, 5))
                .id(id)
                .description("部门描述：" + UUID.randomUUID().toString()).build();
        return dept;
    }

    @Override
    public Integer insertDept(Dept dept) {
        log.info("数据插入成功，dept = {}", dept);
        return dept.getId();
    }
}
